home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 20 / macformat_20.iso / mac / Shareware / Desarrolladores / Sprite Animation Toolkit 2.3.8 / Add-ons / Load faces / FaceFromPICT.p < prev    next >
Text File  |  1996-01-08  |  1KB  |  62 lines

  1. unit FaceFromPICT;
  2.  
  3. interface
  4.     uses
  5. {$IFC UNDEFINED THINK_PASCAL}
  6.         Types, QuickDraw, Memory, Resources, ToolUtils, 
  7. {$ENDC}
  8.         SAT;
  9.  
  10.     function GetFaceFromPICT (colorPICTid, bwPICTid, maskPICTid: integer): FacePtr;
  11.  
  12. implementation
  13.  
  14. {No error checking yet!}
  15.  
  16.     function GetFaceFromPICT (colorPICTid, bwPICTid, maskPICTid: integer): FacePtr;
  17.         var
  18.             bounds: Rect;
  19.             thePICT, maskPICT: PicHandle;
  20.             theFace: FacePtr;
  21.             savePort: SATPort;
  22.     begin
  23.         SATGetPort(savePort);
  24.  
  25. {Get PICTs}
  26. {IDEA: It should really check if the PICT it loads was loaded already, and if it was, don't dispose it.}
  27.         if gSAT.initDepth > 1 then
  28.             thePICT := GetPicture(colorPICTid)
  29.         else
  30.             thePICT := GetPicture(bwPICTid);
  31.         maskPICT := GetPicture(maskPICTid);
  32.  
  33.         if (thePICT = nil) or (maskPICT = nil) then
  34.             begin
  35.                 GetFaceFromPICT := nil;
  36.                 exit(GetFaceFromPICT);
  37.             end;
  38.  
  39.         bounds := thePICT^^.picFrame;
  40.         OffsetRect(bounds, -bounds.left, -bounds.top);
  41.  
  42. {Create face}
  43.         theFace := SATNewFace(bounds);
  44.  
  45. {Draw in the face}
  46.         SATSetPortFace(theFace);
  47.         DrawPicture(thePICT, bounds);
  48.         SATSetPortMask(theFace);
  49.         DrawPicture(maskPICT, bounds);
  50. {Tell SAT that we are done}
  51.         SATChangedFace(theFace);
  52.  
  53. {Get rid of the PICTs}
  54.         ReleaseResource(Handle(thePICT));
  55.         ReleaseResource(Handle(maskPICT));
  56.  
  57. {Return the face.}
  58.         GetFaceFromPICT := theFace;
  59.  
  60.         SATSetPort(savePort);
  61.     end;
  62. end.